24. Exercise: Add Loading Polish

Add Loading Polish and Error Messages to Sunshine

In this Exercise, you will get to apply what you've learned about adding polish to Sunshine.

Exercise Code

Exercise:S02.03-Exercise-Polish

Add code and views to display an error message for a failed data retrieval, and loading indicators for loading data.

SOLUTION:
  • Add a string resource for an error message, should loading data fail.
  • Add a TextView that you will show the user if there is an error loading content.
  • Add a ProgressBar to show the user content is loading.
  • In onPostExecute, show the error message, progress bar, or data views as appropriate.
  • Override the method onPreExecute and show the loading indicator.